package com.designpattern.softwaredesignpatternstudy.pattern.factory;

/**
 * @Author: Jiangxx
 * @Date: 2021/10/08
 * @Description: 简单工厂模式实例
 */
public class Client {
    public static void main(String[] args) {
    }

    public interface Product{
        void show();
    }
    static class ConcreteProduct1 implements Product{

        @Override
        public void show() {
            System.out.println("产品1...");
        }
    }

    static class ConcreteProduct2 implements Product{

        @Override
        public void show() {
            System.out.println("产品2...");
        }
    }

    final class Const {
        static final int PRODUCT_A = 1;
        static final int PRODUCT_B = 2;
        static final int PRODUCT_C = 3;
    }

    static class SimpleFactory {
        static Product makeProduct(int kind) {
            switch (kind) {
                case Const.PRODUCT_A:
                    return new ConcreteProduct1();
                case Const.PRODUCT_B:
                    return new ConcreteProduct2();
                default: return null;
            }
        }
    }
}

